package com.niit.gams.business.controller;

import com.github.pagehelper.PageInfo;
import com.niit.gams.business.pojo.Singer;
import com.niit.gams.business.service.SingerService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/singers")
public class SingerController {
  private SingerService singerService;

  public SingerController(SingerService singerService) {
    this.singerService = singerService;
  }

  @GetMapping
  public ResponseEntity<PageInfo<Singer>> getSinger(@RequestParam(defaultValue = "1") Integer curPage, @RequestParam(defaultValue = "2")Integer pageSize){
    PageInfo<Singer> pageInfo = singerService.findSingers(curPage,pageSize);
    return ResponseEntity.ok(pageInfo);
  }


  @GetMapping("/list")
  public ModelAndView toSingerList(){
    ModelAndView mav = new ModelAndView();
    mav.setViewName("/business/singer");
    return mav;
  }

}
